<?php
function hashimg($path)
{
	return substr(md5('Z6$3S@@!'.$path.'sd###2'),6,30);
}

$return = array();
$imgurl = $_GET['img'];
$chksum = $_GET['c'];
if($chksum !== hashimg($imgurl))
{
	$return['msg'] = 'checkerr';
	die(json_encode($return));
}
if(substr($imgurl,0,21) != 'http://img.ixuepin.us')
{
	$return['msg'] = 'domainerr';
	die(json_encode($return));
}

$file_info = pathinfo($imgurl);

$f = new SaeFetchurl();
$content = $f->fetch($imgurl);
if ($content === false)
{
	$return['msg'] = $f->errmsg();
	die(json_encode($return));
}

$s = new SaeStorage();
$fileurl = $s->write( 'wordpress' , $file_info['filename'].'.'.$file_info['extension'] , $content );
$return['msg'] = '';
$return['url'] = $fileurl;
die(json_encode($return));